﻿CREATE TABLE [dbo].[Contacts] (
    [Id] [int] NOT NULL IDENTITY,
    [Address] [nvarchar](max) NOT NULL,
    [Phone] [nvarchar](max) NOT NULL,
    [Skype] [nvarchar](max) NOT NULL,
    CONSTRAINT [PK_dbo.Contacts] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Educations] (
    [Id] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](max) NOT NULL,
    [Resume_Id] [int],
    CONSTRAINT [PK_dbo.Educations] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_Resume_Id] ON [dbo].[Educations]([Resume_Id])
CREATE TABLE [dbo].[Users] (
    [Id] [int] NOT NULL IDENTITY,
    [Login] [nvarchar](50) NOT NULL,
    [Password] [nvarchar](max) NOT NULL,
    [Email] [nvarchar](max) NOT NULL,
    CONSTRAINT [PK_dbo.Users] PRIMARY KEY ([Id])
)
CREATE UNIQUE INDEX [IX_Login] ON [dbo].[Users]([Login])
CREATE TABLE [dbo].[Roles] (
    [Id] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](max) NOT NULL,
    CONSTRAINT [PK_dbo.Roles] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Languages] (
    [Id] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](max) NOT NULL,
    [UserLanguage_Id] [int],
    CONSTRAINT [PK_dbo.Languages] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_UserLanguage_Id] ON [dbo].[Languages]([UserLanguage_Id])
CREATE TABLE [dbo].[LevelLanguages] (
    [Id] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](max) NOT NULL,
    [UserLanguage_Id] [int],
    CONSTRAINT [PK_dbo.LevelLanguages] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_UserLanguage_Id] ON [dbo].[LevelLanguages]([UserLanguage_Id])
CREATE TABLE [dbo].[Resumes] (
    [Id] [int] NOT NULL IDENTITY,
    [Target] [nvarchar](max) NOT NULL,
    [Work_Experience] [nvarchar](max) NOT NULL,
    [Additional_Information] [nvarchar](max) NOT NULL,
    [Work_on_SectionsID] [int] NOT NULL,
    CONSTRAINT [PK_dbo.Resumes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Sities] (
    [Id] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](max) NOT NULL,
    [Resume_Id] [int],
    CONSTRAINT [PK_dbo.Sities] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_Resume_Id] ON [dbo].[Sities]([Resume_Id])
CREATE TABLE [dbo].[UserLanguages] (
    [Id] [int] NOT NULL IDENTITY,
    [Resume_Id] [int],
    [Vacancy_Id] [int],
    CONSTRAINT [PK_dbo.UserLanguages] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_Resume_Id] ON [dbo].[UserLanguages]([Resume_Id])
CREATE INDEX [IX_Vacancy_Id] ON [dbo].[UserLanguages]([Vacancy_Id])
CREATE TABLE [dbo].[Vacancies] (
    [Id] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](max) NOT NULL,
    [Salary] [decimal](18, 2) NOT NULL,
    [Demands] [nvarchar](max) NOT NULL,
    [Job_Description] [nvarchar](max) NOT NULL,
    CONSTRAINT [PK_dbo.Vacancies] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[WorkOnSections] (
    [Id] [int] NOT NULL IDENTITY,
    [Name] [nvarchar](max) NOT NULL,
    CONSTRAINT [PK_dbo.WorkOnSections] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserRoles] (
    [User_Id] [int] NOT NULL,
    [Roles_Id] [int] NOT NULL,
    CONSTRAINT [PK_dbo.UserRoles] PRIMARY KEY ([User_Id], [Roles_Id])
)
CREATE INDEX [IX_User_Id] ON [dbo].[UserRoles]([User_Id])
CREATE INDEX [IX_Roles_Id] ON [dbo].[UserRoles]([Roles_Id])
CREATE TABLE [dbo].[Employee] (
    [Id] [int] NOT NULL,
    [Name] [nvarchar](max) NOT NULL,
    [LastName] [nvarchar](max) NOT NULL,
    [BirthDay] [datetime] NOT NULL,
    [Phone] [nvarchar](max) NOT NULL,
    [CityID] [int] NOT NULL,
    CONSTRAINT [PK_dbo.Employee] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_Id] ON [dbo].[Employee]([Id])
CREATE TABLE [dbo].[Employer] (
    [Id] [int] NOT NULL,
    [Name] [nvarchar](max) NOT NULL,
    [Salary] [int] NOT NULL,
    [CityID] [int] NOT NULL,
    [ContactID] [int] NOT NULL,
    CONSTRAINT [PK_dbo.Employer] PRIMARY KEY ([Id])
)
CREATE INDEX [IX_Id] ON [dbo].[Employer]([Id])
ALTER TABLE [dbo].[Educations] ADD CONSTRAINT [FK_dbo.Educations_dbo.Resumes_Resume_Id] FOREIGN KEY ([Resume_Id]) REFERENCES [dbo].[Resumes] ([Id])
ALTER TABLE [dbo].[Languages] ADD CONSTRAINT [FK_dbo.Languages_dbo.UserLanguages_UserLanguage_Id] FOREIGN KEY ([UserLanguage_Id]) REFERENCES [dbo].[UserLanguages] ([Id])
ALTER TABLE [dbo].[LevelLanguages] ADD CONSTRAINT [FK_dbo.LevelLanguages_dbo.UserLanguages_UserLanguage_Id] FOREIGN KEY ([UserLanguage_Id]) REFERENCES [dbo].[UserLanguages] ([Id])
ALTER TABLE [dbo].[Sities] ADD CONSTRAINT [FK_dbo.Sities_dbo.Resumes_Resume_Id] FOREIGN KEY ([Resume_Id]) REFERENCES [dbo].[Resumes] ([Id])
ALTER TABLE [dbo].[UserLanguages] ADD CONSTRAINT [FK_dbo.UserLanguages_dbo.Resumes_Resume_Id] FOREIGN KEY ([Resume_Id]) REFERENCES [dbo].[Resumes] ([Id])
ALTER TABLE [dbo].[UserLanguages] ADD CONSTRAINT [FK_dbo.UserLanguages_dbo.Vacancies_Vacancy_Id] FOREIGN KEY ([Vacancy_Id]) REFERENCES [dbo].[Vacancies] ([Id])
ALTER TABLE [dbo].[UserRoles] ADD CONSTRAINT [FK_dbo.UserRoles_dbo.Users_User_Id] FOREIGN KEY ([User_Id]) REFERENCES [dbo].[Users] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserRoles] ADD CONSTRAINT [FK_dbo.UserRoles_dbo.Roles_Roles_Id] FOREIGN KEY ([Roles_Id]) REFERENCES [dbo].[Roles] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[Employee] ADD CONSTRAINT [FK_dbo.Employee_dbo.Users_Id] FOREIGN KEY ([Id]) REFERENCES [dbo].[Users] ([Id])
ALTER TABLE [dbo].[Employer] ADD CONSTRAINT [FK_dbo.Employer_dbo.Users_Id] FOREIGN KEY ([Id]) REFERENCES [dbo].[Users] ([Id])
CREATE TABLE [dbo].[__MigrationHistory] (
    [MigrationId] [nvarchar](150) NOT NULL,
    [ContextKey] [nvarchar](300) NOT NULL,
    [Model] [varbinary](max) NOT NULL,
    [ProductVersion] [nvarchar](32) NOT NULL,
    CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey])
)
INSERT [dbo].[__MigrationHistory]([MigrationId], [ContextKey], [Model], [ProductVersion])
VALUES (N'201501150836062_Init', N'DB_EntityFramework.Migrations.Configuration',  0x1F8B0800000000000400ED1D5D6FDCB8F1BD40FF83A0A7BB22E7B57328901AF61D1CAF53F81AC746D649FBB6A0257A2D441F7B92D6B551F497F5A13FA97FA1A44449FC1629713F1C2F02045E92331CCE0CC9E16838FCDF7FFE7BF2EB53127B8F302FA22C3DF58F0E0E7D0FA6411646E9E2D45F95F73FBDF37FFDE58F7F38B9089327EF6BD3EE67DC0E41A6C5A9FF5096CBE3C9A4081E60028A83240AF2ACC8EECB83204B2620CC266F0F0FFF32393A9A4084C247B83CEFE4F32A2DA304563FD0CFF32C0DE0B25C81F82A0B615C90725433ABB07A9F40028B2508E0A93F7D3FBF40C0E5F3871C15FE33CBBF1D7C29607E0552B04044FBDE591C0144D60CC6F7BE07D2342B4189883E46AD66659EA58BD9121580F8F6790951BB7B1017900CE6B86B6E3AAEC3B7785C930EB04115AC8A324B2C111EFD4C1835E1C107B1DB6F19895859730D8FBA62E7A98FB85E82A0F43DBEAFE3F338C7EDA4CC26506F3CB1EE4DAB20488FF0BF37DEF92A2E57393C4DE1AACC41FCC6BB59DDC551F037F87C9B7D83E969BA8A639A4A4427AA630A50D14D9E2D615E3E7F86F784F6CBD0F7262CDC84076CC128987A589769F9F35BDFFB843A0777316C958062C1ACCC72F85798C21C9430BC016509F314E380D59885DEB9BECEC2308745D1748814AFD2CD2BF0F411A68BF2E1D4477FFADE87E809864D0921E24B1AA1F98780CA7C052544EA3BBE79C852B8F96E67DF5087EBEEF664D2E9B056B32FC25540668D956EB7707BEDD6F685FFDF1D6127CB387B86D056D604CCA5A8BDF7A080842D68FBA936267FEB9C147BFD088A723B3DBF8FF2F2610A9E9B9EA748FF6EA3E4C5AC73E7484D2EA77D336D901E7FCE6258582A7105B35FAC76618A7D028FD1A22298EB1F2F0248AE9F615CD5160FD1925A1EE6588488803C4BF05F75F3AA707E0BF20544E6D96DC6D7CCB2551E0CD5B36A51B253330CB2D732FD929AA1D38746CDFE7CB8166B0F14051244B8F985F0220151BCCD6955CF1BFB59D5CC1D715635F36D8C15623BB31AB0D76885CC400CF2679BBDD4C57E2CC1519F68D7B4AD7F04E9620516B6E66903B65F76B7AEB9E6A2868F301E2A6F1A762FF49723F4CFB05825B6D2AE81F662D6F6D5DABF1BDE97FE8EC430BF784245114C832D6C8C676118610682787E99DE6779427C595B614496CE6730A86C2CEB8D5669BCB58E36F9C1A89E1E73BA5567CA0995824927B69099763AFA66483DB5A49106025555B98AA0BAD296166CBE351B839626AEA1401B53AFA2916D34CA249E5573DC6A5DC420FB55F1E56C7EB4B60CF029ECED1DB9C8956B817E1DA0593A97AE04F216D233B1A499EDCAC5D8B4262473ED557433CD7A8867DB8E5ACFBE8200A481ED9246A0F62ABEF555ADCF033185419480D8F76E72F417098878E77BB300608CF68E8529444A126EE123F06FD9DD7C0A8B208F961BB21C47582F6482A8CD17690361DACB5B8D9AF0D8FEBD4E1BEBD772DEB3C0FBE9BFF5E9AF12FB59516441540D83D2D9DA83CC127D91869ED29DCCF95BBD2B24CA68898487BA3CF5FF247040868C3BF156B67DFD55508BED64428D413F34F164A5A24A73CCA2A823CE0F96BCC3838323CD78D5C7330A3315C2E178ECF5D1AD8738EE1CE766C4ECF98F425A9F945C8D536106EAD44F6713B28ADD59FB561CE8B128A94E541DB8E2076B639AD1AB3038D7C019B9B94AB387F5313B9E1BEC1EDCA3CE8AFDD8CD5C916FE3862C1FCE07B931A2A2B5C732E9886D8F0E56ACD09B348E79516F8ED5B7B0086DE3D4DCC165F04916278A6A890954902D981F0AC6398325FBA50DED67DD564C86D006A30ADC6051D03E410109B569F4A0A9BF0F0B08C86EDB034C223A04E87AE3EF01EEE424C077557D38B883B288895D25FA98514D39199E6606F72020DE50017C2633FD64DCD48D8555EE1E64D59429A4C4B473B0070536DC0BDAEC1730F1E7020E2135C1D85192A804AA5E0859E04D799DC9D912DE6AE4C404BC593F28F09A2EFE80C08EC3608C12B7BD38D61E0BD4D006A5896FB457337AB5C94921A2E976C50B3233946C9018A3FDE6E8B0C1B3D6278583D0387AC82AF7A35CDFFB2C541B1B959B0954DF3D33426392523895ABCF581E71CB781FA334A6ABB5F1EA8065725B95E61B373E57938A235839B934469CB93D3B6CB2C94D3653A60F608DC28B26F2C6C0C2B5B071A911755BAF863D7A93D6017F1A2F4F6BC8B6752793FA3219293899286E9D9D5C81E5324A17D42D3452E2CDEA2B68E73FCDECAF6325358E4950486E65B5D4B63D95598E46CED5620B3A841FA2BC28A7A0047700FBB8CEC34468469BED0A6BA7E989B3CC45D135C64F0380FF26FE6DFD55BCD6A6E770760C45708B04A665355C48495F09E9E12B81D86B2F71569E67F12A49550E4F1D747B5B8B46D1169AE3219712682CA4C81C07B94945E32045228E9309C7485E7A13417CDC3CE2D5C14859B4B6DB7075E94E6FF60AA3815D8FCAD41E6B1ABE2ED91921D54702A7F2692E5A0D108F1274DBD25161E8AE48D158BA52734CDD95271A5357BAD9E5A50998A6913465EE75B747E32E0BFCF7F5FD0F7DAA877FFC3840EFC4D0F7F5E91CB901C2A84B5D6421E1F63E0723E4B6D41C13B99F41A321451B97B2E1BA221194E9BAB231198F5F579A9003667F2765EB9AC54A2CDDC507065157BC33BB99C239365CE96A4FAFBDC629E0B6AD6E5B124BEB1971291A155203E9A8415FAB80FA7C4623C4C47C6318202B3DFC2B1558E36372BAD6D55F71062C760AC0F5C8A6F102D118E421A73A2CC2ED0D1A9D5069E523905ECAE05C06D23696D473572E840170F53BA3BBAA8F19C335B7FA8068AFB772B057BAA2F4397A874B87F9323BEC70B6AEF57F4BBC6E7DE02ED9DC7CB8B6E7B01272DB5361BDA7A336EE9A46D3169AE311C2A8697C42E5CE28211FC0E05217B9D0077B95EC43B06DCD5CB7CCD80F57E24A4D6244EC166102245B60A5E755FC414E12A7CF8497889C31924B8547261CCC98B6531B7A880938909E6AFC9604F19F17AD05290984B1B5D61960E3AF1D12462A63688632B4C6E740C4CAA09C81945993749EA5B5BDEE5D16F8EA407B6DC068BCAEB48484DF582B088133B17DD5CC67028B7645239848A557A20CAAE0A961D6388DC1D447A65884D5615723768816A9A39D421DC7B553EAD33374C74AC4455F0DD5240E8D951BAF575CD2E0B49D542C69B4DBABD22E79F49DF5BEC5C1DB7805D45B86343A6D57F63369B0DB4EA9CEFAF635455CA2B5F7C3B1DA68A31A078AA6C1E94071B461923BA539EA41F7AB8E10ABC937690FE3A4A4FDDDC66A9238C9FE670384C0C9BA09BEEC9F3D46210E9A9C3D17254C0E708383D9EFF1791CA1E37FD7006964740F8BB2BE89EDBF3D3C7CC73D36B03B89FF2745113217C5D5D9FF59996DE036798499DA7B5FDC3E65169D6F3F7D0479F000F21F12F0F4E3B8DCD2E3503179F16D500DC875FF7D48B276CCB9E03DB5A951F40A97182FD3103E9DFAFFAAA08EBDCB7FCC5BC037DE758E66FEB177E8FD9BEEBECE36303863D277222926E571232A1D832F8B2F69F4FB0A31F9163110B3944B903C32FBF1387561321AAF65AA4A7CB12F56F843A7A97DDEDCD7CD2F119370CCB35BDC38F0352C711A8FC05E7CBB2F3E59D0CF8B951B9B2C619CE4147961C721D5E77A7540B0347F6BC56B37EBB4F8BDE1C52ACB2B303DBFB36579937C167BA77D1F76DD77906B90B334EAE7C58AD8DDA464B33D866BCEF6388E564506C7B558DABA909C57A73656ABE9E0039D3A4A466CAB8A60E96771DB8BBD89A95999CC16E69668CB7599C059746EFF50E07634DC60F42399EE6EA9E41F081C878D7FF42F4453BC1CFDE8DF389AD887831CDAC3F22B897B2D93606237E47E198C97A20403FFF8D37055D02492957E59E412EBF4E6903D12BE6B5EA75318C3127A6741FDA5E91C14010825898A5057BABE49DE3B8E0093DCB30815D25F98E36D1AC4889B459983480C9BBDC9A334889620A647CC35329C13783C2D3ABE660A9730C54683303A93CE34D1AB2D628EB37DA3B74C54AA8E79A5930C09E2928AEABB521873216E546374F1C51B5019DB7CCEE3F3B35239362954A6E99A074B5F7585D1B9F875596824E2D7C50A6D4EFE2639ADC78BBE4EE7496131C85BBDFB0257DC31DC3D598FC8EBED2A59B5149F61E6E1319682E696A1737DB0EACB20E674E39A619FE1DC997AB06987691DB1485BFE6214A52701C2AE6ACB805CEFE3F78E41EAF6E2F6126B15DCF69E3228DFBD83D4F6DB5407F57DEAEDEB833E8678030AD13849E758261DB2397E8EA9F60CDF66738527D5DA9FA13965343D30878CB6D040D776DA2BA149A568DAD7E6742137D105DEDFE95E1772992E08885EAC2E8CE9CBB92E7071F9ADAF944F3ECC8B8C5CC7E042CC35AF7DD451F8A77E789721F1D62ED7EE9510412558FC94D341E881AA93F5A1C9F5CFF752ABABD0415D2CC32D7D8C41FA0289F4C98DBA5C86D8EC7512A3074664E8D5E9B6852E586B5EEC87AD9776A6CF0D2F708BD89C22BB4885945FF27CEDD2E74B94AF97C810A39AC8F09D180D97D86A952699F3A8B5C4849EDA1A592775A5C978F8774F847EF806B2EE7A1E4F91F1503555A83A15F7CCA64C675888EB485B255D46DA5AB31E640B4957A5E9417C5748FFCA4C9BA05FF3D88CE2BA9BB07573B7EC241B90F4DB80341149CF1D31AB2136B19DBA21CAAFCC899F522862A5846E78906B7A4947F29A8576A0C206CB651F71365037CFE4D80E8F5EF7BBDC196E5474030FE128DFCBD00E5A0AFD925FB819C8069909234968E04CC5B9BDDCD1A335B62A3F88713BF81C8DF8F28CF8B2DB56066EE73F913064840366E4DECD5B41ECCB0DCE5863E84E50B366883FC20D6B72196B44D3CCC9EB44E2CD76749E5FA5386EAEFE358545B4E850E0EBFA696D5577489B36F86A49E34CE0286A9A70715157B004213AE69FE565748F4EE3A83A804551BDCCFD15C4AB8A297730BC4CAF57E57255A221C3E42E662621764CE8FAAF9E6062693EB9AEE29D0B174340644638D4F03A7DBF8AE2B0A5FB8324A44B81027B3C485032966589839317CF2DA64FC2E31B2A44847DADA3E61622E541C8709E46F00887D08694F6235C80E0B94950A046D22F0896ED27D3082C7290140447078F7E221D0E93A75FFE0F1BFC9C3F3DA20000 , N'6.1.2-31219')

